package com.itheima.day05_多态和内部类.develophomework01.homework03;

public class Test03 {
    /*
    （1）定义一个类，描述一个矩形，包含有长、宽两种属性，和计算面积方法。
    （2）编写一个类，继承自矩形类，同时该类描述长方体，具有长、宽、高属性，和计算体积的方法。
    （3）编写一个测试类，对以上两个类进行测试，创建一个长方体，定义其长、宽、高，输出其底面积和体积。
     */
    public static void main(String[] args) {
        Cuboid cu = new Cuboid(3,4,5);
        int res = cu.broom();
        int r = cu.area();
        System.out.println(res);
        System.out.println("r = " + r);
    }
}
class Rectangle{
    private int length;
    private int width;

    public int area(){
        return length*width;
    }

    public Rectangle() {
    }

    public Rectangle(int length, int width) {
        this.length = length;
        this.width = width;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }
}

class Cuboid extends Rectangle{
    private int high;

    public int broom(){
        return area()*high;
    }

    public Cuboid() {
    }

    public Cuboid(int length, int width, int high) {
        super(length, width);
        this.high = high;
    }

    public int getHigh() {
        return high;
    }

    public void setHigh(int high) {
        this.high = high;
    }
}